<!DOCTYPE html>
<html lang="en">
    <head>
        <title>京伦内容管理系统</title>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="__PUBLIC__/bootstrap/css/bootstrap.min.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/ui/jquery.ui.all.css" />
        <script src="__PUBLIC__/js/jquery-1.7.2.min.js"></script>
        <script src="__PUBLIC__/js/ui/jquery.ui.core.js"></script>
        <script src="__PUBLIC__/js/ui/jquery.ui.widget.js"></script>
        <script src="__PUBLIC__/js/ui/jquery.ui.mouse.js"></script>
        <script src="__PUBLIC__/js/ui/jquery.ui.sortable.js"></script>
        <script src="__PUBLIC__/js/ui/jquery.ui.droppable.js"></script>
        <script src="__PUBLIC__/js/ui/jquery.ui.tabs.js"></script>
        <style type="text/css">
            body {
                padding-top: 50px;
            }
            .starter-template {
                padding: 40px 15px;
                text-align: center;
            }

            /*
             * Global add-ons
            */

            .sub-header {
                padding-bottom: 10px;
                border-bottom: 1px solid #eee;
            }

            /*
             * Top navigation
             * Hide default border to remove 1px line.
            */
            .navbar-fixed-top {
                border: 0;
            }

            /*
             * Sidebar
            */

            /* Hide for mobile, show later */
            .sidebar {
                display: none;
            }
            @media (min-width: 768px) {
                .sidebar {
                    position: fixed;
                    top: 51px;
                    bottom: 0;
                    left: 0;
                    z-index: 1000;
                    display: block;
                    padding: 20px;
                    overflow-x: hidden;
                    overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
                    background-color: #f5f5f5;
                    border-right: 1px solid #eee;
                }
            }

            /* Sidebar navigation */
            .nav-sidebar {
                margin-right: -21px; /* 20px padding + 1px border */
                margin-bottom: 20px;
                margin-left: -20px;
            }
            .nav-sidebar > li > a {
                padding-right: 20px;
                padding-left: 20px;
            }
            .nav-sidebar > .active > a,
            .nav-sidebar > .active > a:hover,
            .nav-sidebar > .active > a:focus {
                color: #fff;
                background-color: #428bca;
            }


            /*
             * Main content
            */

            .main {
                padding: 20px;
            }
            @media (min-width: 768px) {
                .main {
                    padding-right: 40px;
                    padding-left: 40px;
                }
            }
            .main .page-header {
                margin-top: 0;
            }


            /*
             * Placeholder dashboard ideas
            */

            .placeholders {
                margin-bottom: 30px;
                text-align: center;
            }
            .placeholders h4 {
                margin-bottom: 0;
            }
            .placeholder {
                margin-bottom: 20px;
            }
            .placeholder img {
                display: inline-block;
                border-radius: 50%;
            }
        </style>
        <!--拖动css和js-->
        <style>
            .cando .ui-state-default { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 250px; }
            #sortable { list-style-type: none; margin: 0; padding: 0; width: 100%; }
            #sortable li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; height: 2.0em; }
            .one {background:#fcfcfc;}
            #sortable .controls{float:right;margin-right:20px;}
            #sortable .controls a{margin-right:20px;}
        </style>
        <script>
            $(function() {
                $( ".cando" ).sortable().disableSelection();

                var $tabs = $( "#tabs" ).tabs();
                var $tab_items = $( "ul:first li", $tabs ).droppable({
                    accept: ".cando li",
                    hoverClass: "ui-state-hover",
                    drop: function( event, ui ) {
                        var $item = $( this );
                        var $list = $( $item.find( "a" ).attr( "href" ) ).find( ".cando" );
                        /* 				ui.draggable.hide( "slow");
                         $( this ).appendTo( $list ); */
                        ui.draggable.hide( "normal", function() {
                            //$tabs.tabs( "select", $tab_items.index( $item ) );
                            $( this ).appendTo( $list ).show( "slow" );
                        });
                    }
                });


                $( "#sortable" ).sortable({
                    placeholder: "ui-state-highlight"
                });
                $( "#sortable" ).disableSelection();



            });
        </script>
        <!--end-->
    </head>
    <body screen_capture_injected="true" ryt12591="1">
    <include file="Public:header" />
    <div class="container-fluid">
        <div class="row">
            <include file="left" />
            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                <div class="page-header"><a href="{:U(Index/index)}">Home</a>-><a href="">模型管理</a></div>
                <div class="row placeholders">
                    <div class="col-xs-6 col-sm-3 placeholder">
                        <img data-src="holder.js/200x200/auto/sky" class="img-responsive" alt="Generic placeholder thumbnail">
                        <h4>Label</h4>
                        <span class="text-muted">Something else</span>
                    </div>
                    <div class="col-xs-6 col-sm-3 placeholder">
                        <img data-src="holder.js/200x200/auto/vine" class="img-responsive" alt="Generic placeholder thumbnail">
                        <h4>Label</h4>
                        <span class="text-muted">Something else</span>
                    </div>
                    <div class="col-xs-6 col-sm-3 placeholder">
                        <img data-src="holder.js/200x200/auto/sky" class="img-responsive" alt="Generic placeholder thumbnail">
                        <h4>Label</h4>
                        <span class="text-muted">Something else</span>
                    </div>
                    <div class="col-xs-6 col-sm-3 placeholder">
                        <img data-src="holder.js/200x200/auto/vine" class="img-responsive" alt="Generic placeholder thumbnail">
                        <h4>Label</h4>
                        <span class="text-muted">Something else</span>
                    </div>
                </div>
                <div class="table-responsive">
                    <div class="demo" style="padding:10px;">
                        <ul id="sortable">
                            <if condition="$arr2 eq ''">
                                <li>暂时没有字段</li>
                                <else/>
                                {$flist}
                            </if>
                        </ul>
                    </div>
                    <div style="text-align: center;">
                        <a href="{:U('Model/fieldadd',array('mid'=>$mid))}" class="btn btn-large btn-primary">添加字段</a>
                        <a href="javascript:void(0)" onclick="savenav()" class="btn btn-large btn-primary">保存顺序</a>
                        <a href="{:U('Model/index')}" class="btn btn-large btn-primary">模型列表</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

<script>
    function savenav(){
        topjson = '';
        var mid = '{$mid}';
        var top= $("#sortable li");
        top.each(function(index){
            var temp = '';
            var id = $(this).attr('_index');
            temp = "{'index':'"+id+"','order':'"+index+"'},";
            topjson+=temp;
        })
		
        topjson = "["+topjson+"]";
                   
        topjson = eval(topjson);

        $.post("{:U('ajax/modelajax')}",{'action':'fieldorder','mid':mid,'data':topjson},function(data){
            if(data!=1){
                alert('保存顺序失败');
            }else{
                alert('保存顺序成功');
            }
			 
        })
		
		
    }
</script>

</html>